package com.atguigu.factory.simplefactory.pizzastore.order;

import com.atguigu.factory.simplefactory.pizzastore.pizza.CheesePizza;
import com.atguigu.factory.simplefactory.pizzastore.pizza.GreekPizza;
import com.atguigu.factory.simplefactory.pizzastore.pizza.PepperPizza;
import com.atguigu.factory.simplefactory.pizzastore.pizza.Pizza;

/**
 * @Description: 简单工厂
 * @Author lixiaolong
 * @Date 2023/9/26
 */
public class SimpleFactory {

	public Pizza createPizza(String orderType) {

		Pizza pizza = null;

		System.out.println("简单工厂");
		if (orderType.equals("greek")) {
			pizza = new GreekPizza();
			pizza.setName("greek");
		} else if (orderType.equals("cheese")) {
			pizza = new CheesePizza();
			pizza.setName("cheese");
		} else if (orderType.equals("pepper")) {
			pizza = new PepperPizza();
			pizza.setName("pepper");
		}
		
		return pizza;
	}
	

	public static Pizza createPizza2(String orderType) {

		Pizza pizza = null;

		System.out.println("简单工厂2");
		if (orderType.equals("greek")) {
			pizza = new GreekPizza();
			pizza.setName("greek");
		} else if (orderType.equals("cheese")) {
			pizza = new CheesePizza();
			pizza.setName("cheese");
		} else if (orderType.equals("pepper")) {
			pizza = new PepperPizza();
			pizza.setName("pepper");
		}
		
		return pizza;
	}

}
